home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 September (IDG) / Sep99.iso / Shareware World / Info / For Developers / Finder Flags Plugin / Finder Flags Sources / Finder Flags Panel / SetFilePanel.c < prev   
Encoding:
C/C++ Source or Header  |  1999-06-19  |  16.9 KB  |  708 lines  |  [TEXT/CWIE]

  1. /*
  2.  *  SetFilePanel.c - 'SetFile Panel' Drop-In Preferences
  3.  *
  4.  *  Copyright © 1995 metrowerks inc.  All rights reserved.
  5.  *
  6.  */
  7.  
  8. /* prevent access to dialog (for a glimpse of the future...) */
  9. #define CW_STRICT_DIALOGS 1
  10.  
  11. /* standard headers */
  12. #include <stdarg.h>
  13. #include <stdio.h>
  14. #include <string.h>
  15.  
  16. /* system headers */
  17. #include <AERegistry.h>
  18. #include <Drag.h>
  19. #include <Palettes.h>
  20. #include <Resources.h>
  21. #include <Scrap.h>
  22. #include <TextUtils.h>
  23. #include <Sound.h>
  24.  
  25. /* compiler headers */
  26. #include <A4Stuff.h>
  27. #include <SetUpA4.h>
  28. #include <DropInPanel.h>
  29. #include <Files.h>
  30. #include <Finder.h>
  31.  
  32. /* project headers */
  33. #include "SetFilePanel.h"
  34.  
  35.  
  36. /* current version number for our prefs data */
  37. #define PSAMPLEPANELVERSION        3
  38.  
  39.  
  40. enum {
  41.     kFactoryPrefsID = 128,
  42.     kCW7ItemListID = 128,
  43.     kCW8ItemListID,
  44.         
  45.     kSetFileStringsID = 128,
  46.     kSetFileInfoStr = 1
  47. };
  48.  
  49.  
  50. /* prototypes of local functions */
  51. static short    InitDialog(PanelParameterBlock *pb);
  52. static void        TermDialog(PanelParameterBlock *pb);
  53. static void        PutData(PanelParameterBlock *pb, Handle options);
  54. static short    GetData(PanelParameterBlock *pb, Handle options, Boolean noisy);
  55. static short    Filter(PanelParameterBlock *pb, EventRecord *event, short *itemHit);
  56. static void        HandleKey(PanelParameterBlock *pb, EventRecord *event);
  57. static void        HandleClick(PanelParameterBlock *pb, EventRecord *event);
  58. static void        ItemHit(PanelParameterBlock *pb);
  59. static void        FindStatus(PanelParameterBlock *pb);
  60. static void        ObeyCommand(PanelParameterBlock *pb);
  61. static void        Validate(Handle original, Handle current, Boolean *recompile, Boolean *relink, Boolean *reset);
  62. static short    GetPref(AEKeyword keyword, AEDesc *prefsDesc, Handle settings);
  63. static short    SetPref(AEKeyword keyword, const AEDesc *prefsDesc, Handle settings);
  64. static short    GetFactory(Handle settings);
  65. static short    UpdatePref(Handle settings);
  66. static Boolean    ComparePrefs(Handle prefsHand1, Handle prefsHand2);
  67. static void        OutlineRect(const Rect* focusRect, Boolean outlineOn);
  68. static OSErr    DragEnter(PanelParameterBlock *pb);
  69. static void        DragWithin(PanelParameterBlock *pb);
  70. static void        DragExit(PanelParameterBlock *pb);
  71. static void        DragDrop(PanelParameterBlock *pb);
  72. static pascal void    PanelDrawBoxCB(DialogPtr dp, short item);
  73.  
  74.  
  75. /*
  76.  *    main    -    entry-point for Drop-In Preferences Panel
  77.  *
  78.  */
  79.  
  80. pascal short main(PanelParameterBlock *pb)
  81. {
  82.     short    result, theItem;
  83.     
  84.     EnterCodeResource();
  85.     PrepareCallback();
  86.     
  87.     result = noErr;
  88.     // DebugStr("\p SetFilePanel main");        
  89.     switch (pb->request)
  90.     {
  91.     case reqInitPanel:
  92.         /* panel has just been loaded into memory */
  93.         break;
  94.  
  95.     case reqTermPanel:
  96.         /* panel is about to be unloaded from memory */
  97.         break;
  98.  
  99.     case reqInitDialog:
  100.         /* hook our dialog item list into the preferences dialog */
  101.         result = InitDialog(pb);
  102.         break;
  103.         
  104.     case reqTermDialog:
  105.         /* unhook our dialog item list from the preferences dialog */
  106.         TermDialog(pb);
  107.         break;
  108.     
  109.     case reqPutData:
  110.         /* put the data in the given handle into our dialog items */
  111.         PutData(pb, pb->currentPrefs);
  112.         break;
  113.  
  114.     case reqGetData:
  115.         /* fill in the given handle with our dialog items */
  116.         result = GetData(pb, pb->currentPrefs, true);
  117.         break;
  118.  
  119.     case reqFilter:
  120.         /* filter an event in the dialog */
  121.         result = Filter(pb, pb->event, &pb->itemHit);
  122.         break;
  123.         
  124.     case reqItemHit:
  125.         /* handle a hit on one of our dialog items */
  126.         ItemHit(pb);
  127.         break;
  128.         
  129.     case reqDrawCustomItem:
  130.         /* handle a request to draw one of our user items (CW/8 and later) */
  131.         theItem = pb->itemHit - pb->baseItems;
  132.         //switch (theItem) {
  133.         //    default:
  134.         //}
  135.         break;
  136.         
  137.     case reqActivateItem:
  138.         theItem = pb->itemHit - pb->baseItems;
  139.         //if (theItem == kPictItem)
  140.         //{
  141.         //    ActivatePictBox(pb, true);
  142.         //}
  143.         break;
  144.         
  145.     case reqDeactivateItem:
  146.         theItem = pb->itemHit - pb->baseItems;
  147.         //if (theItem == kPictItem)
  148.         //{
  149.         //    ActivatePictBox(pb, false);
  150.         //}
  151.         break;
  152.         
  153.     case reqHandleKey:
  154.         theItem = pb->itemHit - pb->baseItems;
  155.         //if (theItem == kPictItem)
  156.         //{
  157.         //    HandleKey(pb, pb->event);
  158.         //}
  159.         break;
  160.         
  161.     case reqHandleClick:
  162.         theItem = pb->itemHit - pb->baseItems;
  163.         //if (theItem == kPictItem)
  164.         //{
  165.         //    HandleClick(pb, pb->event);
  166.         //}
  167.         break;
  168.         
  169.     case reqFindStatus:
  170.         FindStatus(pb);
  171.         break;
  172.         
  173.     case reqObeyCommand:
  174.         ObeyCommand(pb);
  175.         break;
  176.         
  177.     case reqAEGetPref:
  178.         /* return one item in the given handle as an Apple Event descriptor */
  179.         result = GetPref(pb->prefsKeyword, &pb->prefsDesc, pb->currentPrefs);
  180.         break;
  181.  
  182.     case reqAESetPref:
  183.         /* change one item in the given handle according to the given Apple Event descriptor */
  184.         result = SetPref(pb->prefsKeyword, &pb->prefsDesc, pb->currentPrefs);
  185.         break;
  186.  
  187.     case reqValidate:
  188.         /* determine if we need to reset paths, recompile, or relink */
  189.         Validate(pb->originalPrefs, pb->currentPrefs, &pb->recompile, &pb->relink, &pb->reset);
  190.         break;
  191.  
  192.     case reqGetFactory:
  193.         /* return our factory settings */
  194.         result = GetFactory(pb->factoryPrefs);
  195.         break;
  196.  
  197.     case reqUpdatePref:
  198.         /* update the given handle to use the current format for our prefs data */
  199.         result = UpdatePref(pb->currentPrefs);
  200.         break;
  201.         
  202.     default:
  203.         result = paramErr;
  204.         break;
  205.     }
  206.     
  207.     ExitCodeResource();
  208.     
  209.     return (result);
  210. }
  211.  
  212.  
  213. /*
  214.  *    InitDialog  -    initialize Dialog Box items for this panel
  215.  *
  216.  */
  217.  
  218. static short InitDialog(PanelParameterBlock *pb)
  219. {
  220.     short    ditlID;
  221.     OSErr    err;
  222.     
  223.     // The library function will call the IDE to append the dialog items 
  224.     // if possible;  else it will call AppendDITL itself.  This way, you 
  225.     // don't have to worry about it.
  226.     
  227.     if (pb->version < DROPINPANELAPIVERSION_2)
  228.         ditlID = kCW7ItemListID;
  229.     else
  230.         ditlID = kCW8ItemListID;
  231.     
  232.     err = CWPanlAppendItems(pb, ditlID);
  233.     
  234.     return (err);
  235. }
  236.  
  237. /*
  238.  *    TermDialog    -    destroy Dialog Box items for this panel
  239.  *
  240.  */
  241.  
  242. static void TermDialog(PanelParameterBlock *pb)
  243. {
  244. #pragma unused (pb)
  245. }
  246.  
  247. /*
  248.  *    PutData        -    copy the options data from the handle to the screen
  249.  *
  250.  */
  251.  
  252. static void PutData(PanelParameterBlock *pb, Handle options)
  253. {
  254.     SetFilePref        prefsData = ** (SetFilePrefHandle) options;
  255.     UInt8    typeStr[] = {4,0,0,0,0};
  256.     
  257.  
  258.     CWPanlSetItemValue(pb, kAliasItem, prefsData.bits.alias);
  259.     CWPanlSetItemValue(pb, kInvisibleItem, prefsData.bits.invisible);
  260.     CWPanlSetItemValue(pb, kBundleItem, prefsData.bits.bundle);
  261.     CWPanlSetItemValue(pb, kSystemItem, prefsData.bits.system);
  262.     CWPanlSetItemValue(pb, kStationaryItem, prefsData.bits.stationary);
  263.     CWPanlSetItemValue(pb, kCustomIconItem, prefsData.bits.customIcon);
  264.     CWPanlSetItemValue(pb, kLockedItem, prefsData.lock);
  265.     CWPanlSetItemValue(pb, kInitedItem, prefsData.bits.inited);
  266.     CWPanlSetItemValue(pb, kNoInitsItem, prefsData.bits.noinits);
  267.     CWPanlSetItemValue(pb, kSharedItem, prefsData.bits.shared);
  268.     CWPanlSetItemValue(pb, kDeskTopItem, prefsData.bits.onDesk);
  269.     CWPanlSetItemValue(pb, kRoutingItem, prefsData.xbits.routing);
  270.     CWPanlSetItemValue(pb, kBadgeItem, prefsData.xbits.badge);
  271.     BlockMove(&prefsData.creator,&typeStr[1],4);
  272.     CWPanlSetItemText (pb, kCreatorItem, typeStr);
  273.     BlockMove(&prefsData.type,&typeStr[1],4);
  274.     CWPanlSetItemText (pb, kTypeItem, typeStr);    
  275.     if (pb->version < DROPINPANELAPIVERSION_2)
  276.     {
  277. #if 0
  278.         CWPanlActivateItem(pb, kOutFileItem);
  279. #endif
  280.     }
  281. }
  282.  
  283. /*
  284.  *    GetData        -    copy the options data from screen to the handle
  285.  *
  286.  */
  287.  
  288. static short GetData(PanelParameterBlock *pb, Handle options, Boolean noisy)
  289. {
  290.     SetFilePref    prefsData    = ** (SetFilePrefHandle) options;
  291.     long        symval;
  292.     OSErr        err;
  293.     UInt8        typeStr[32];
  294.     
  295.     CWPanlGetItemValue(pb, kAliasItem, &symval);
  296.     prefsData.bits.alias = symval;
  297.     CWPanlGetItemValue(pb, kInvisibleItem, &symval);
  298.     prefsData.bits.invisible = symval;
  299.     CWPanlGetItemValue(pb, kBundleItem, &symval);
  300.     prefsData.bits.bundle = symval;
  301.     CWPanlGetItemValue(pb, kSystemItem, &symval);
  302.     prefsData.bits.system = symval;
  303.     CWPanlGetItemValue(pb, kStationaryItem, &symval);
  304.     prefsData.bits.stationary = symval;
  305.     CWPanlGetItemValue(pb, kCustomIconItem, &symval);
  306.     prefsData.bits.customIcon = symval;
  307.     CWPanlGetItemValue(pb, kLockedItem, &symval);
  308.     prefsData.lock = symval;
  309.     CWPanlGetItemValue(pb, kInitedItem, &symval);
  310.     prefsData.bits.inited = symval;
  311.     CWPanlGetItemValue(pb, kNoInitsItem, &symval);
  312.     prefsData.bits.noinits = symval;
  313.     CWPanlGetItemValue(pb, kSharedItem, &symval);
  314.     prefsData.bits.shared = symval;
  315.     CWPanlGetItemValue(pb, kDeskTopItem, &symval);
  316.     prefsData.bits.onDesk = symval;
  317.     CWPanlGetItemValue(pb, kRoutingItem, &symval);
  318.     prefsData.xbits.routing = symval;
  319.     CWPanlGetItemValue(pb, kBadgeItem, &symval);
  320.     prefsData.xbits.badge = symval;
  321.     err = CWPanlGetItemText (pb, kCreatorItem, typeStr,31);
  322.     if (err != noErr) {
  323.         // An error occurred while retrieving the text.  It was probably too 
  324.         // long to fit in the given length.  If we're in "noisy" mode, alert 
  325.         // the user.
  326.         
  327.         if (noisy)
  328.         {
  329.             SysBeep(10);
  330.             CWPanlActivateItem(pb, kCreatorItem);
  331.             return (userCanceledErr);
  332.         }
  333.     } else {
  334.         BlockMove(&typeStr[1],&prefsData.creator,4);
  335.     }
  336.     err = CWPanlGetItemText (pb, kTypeItem, typeStr,31);    
  337.     if (err != noErr) {
  338.         // An error occurred while retrieving the text.  It was probably too 
  339.         // long to fit in the given length.  If we're in "noisy" mode, alert 
  340.         // the user.
  341.         
  342.         if (noisy)
  343.         {
  344.             SysBeep(10);
  345.             CWPanlActivateItem(pb, kTypeItem);
  346.             return (userCanceledErr);
  347.         }
  348.     } else {
  349.         BlockMove(&typeStr[1],&prefsData.type,4);
  350.     }
  351.     prefsData.bits.rsvd0x0200 = 0;
  352.     prefsData.bits.rsvd0x003e = 0;
  353.     prefsData.xbits.rsvd0xFE00 = 0;
  354.     prefsData.xbits.rsvd0x00F8 = 0;
  355.     prefsData.xbits.rsvd0x0003 = 0;
  356.     ** (SetFilePrefHandle) options = prefsData;
  357.     
  358.     return (noErr);
  359. }
  360.  
  361. /*
  362.  *    Filter        -    filter an event for the Preferences panel
  363.  *
  364.  */
  365. static short Filter(PanelParameterBlock *pb, EventRecord *event, short *itemHit)
  366. {
  367. #pragma unused(pb, event, itemHit)
  368.     
  369.     return (noErr);
  370. }
  371.  
  372. /*
  373.  *    HandleKey
  374.  *
  375.  */
  376. static void HandleKey(PanelParameterBlock *pb, EventRecord *event)
  377. {
  378. #pragma unused(pb,event)
  379. }
  380.  
  381. /*
  382.  *    HandleClick
  383.  *
  384.  */
  385. static void HandleClick(PanelParameterBlock *pb, EventRecord *event)
  386. {
  387. #pragma unused(pb,event)
  388. }
  389.  
  390. /*
  391.  *    ItemHit        -    handle an itemHit in a Preferences panel
  392.  *
  393.  */
  394.  
  395. static void ItemHit(PanelParameterBlock *pb)
  396. {
  397.     short    theItem    = pb->itemHit - pb->baseItems;
  398.     long    oldValue;
  399.     
  400.     // DebugStr("\p SetFilePanel ItemHit");        
  401.     switch (theItem)
  402.     {
  403.         case     kAliasItem:
  404.         case     kInvisibleItem:
  405.         case     kBundleItem:
  406.         case     kSystemItem:
  407.         case     kStationaryItem:
  408.         case     kCustomIconItem:
  409.         case     kLockedItem:
  410.         case     kInitedItem:
  411.         case     kNoInitsItem:
  412.         case     kSharedItem:
  413.         case     kDeskTopItem:
  414.         case    kBadgeItem:
  415.         case    kRoutingItem:
  416.             CWPanlGetItemValue(pb, theItem, &oldValue);
  417.             CWPanlSetItemValue(pb, theItem, !oldValue);
  418.             break;
  419.             
  420.         default:
  421.             break;
  422.     }
  423.     
  424.     GetData(pb, pb->currentPrefs, false);
  425.     
  426.     pb->canRevert    = !ComparePrefs(pb->originalPrefs, pb->currentPrefs);
  427.     pb->canFactory    = !ComparePrefs(pb->factoryPrefs,  pb->currentPrefs);
  428. }
  429.  
  430. /*
  431.  *    FindStatus
  432.  *
  433.  */
  434. static void FindStatus(PanelParameterBlock *pb)
  435. {
  436.     short    command    = pb->itemHit;
  437.     Boolean    enabled    = false;
  438.     
  439.     pb->itemHit = enabled;
  440. }
  441.  
  442. /*
  443.  *    ObeyCommand
  444.  *
  445.  */
  446.  
  447. static void ObeyCommand(PanelParameterBlock *pb)
  448. {
  449.     pb->itemHit = 0;
  450. }
  451.  
  452. /*
  453.  *    Validate    -    check if panel's changes require a recompile or relink
  454.  *
  455.  */
  456.  
  457. static void Validate(Handle original, Handle current, Boolean *recompile, Boolean *relink, Boolean *reset)
  458. {
  459.     *recompile    = false;
  460.     *relink        = !ComparePrefs (original, current);
  461.     *reset        = false;
  462. }
  463.  
  464. /*
  465.  *    GetPref        -    get a specified Preference setting for an AppleEvent request
  466.  *
  467.  */
  468.  
  469. static short GetPref(AEKeyword keyword, AEDesc *prefsDesc, Handle settings)
  470. {
  471.     SetFilePref    prefsData    = ** (SetFilePrefHandle) settings;
  472.     DescType    anEnum;
  473.     OSErr        err;
  474. #pragma unused(keyword,prefsDesc,anEnum)
  475.     switch (keyword)
  476.     {
  477.  
  478. #if 0        
  479.     case prefsPR_ProjectType:
  480.         switch (prefsData.projtype)
  481.         {
  482.         case kProjTypeApplication:    anEnum = enum_Project_Application;        break;
  483.         case kProjTypeLibrary:        anEnum = enum_Project_Library;            break;
  484.         case kProjTypeSharedLib:    anEnum = enum_Project_SharedLibrary;    break;
  485.         case kProjTypeCodeResource:    anEnum = enum_Project_CodeResource;        break;
  486.         case kProjTypeMPWTool:        anEnum = enum_Project_MPWTool;            break;
  487.         default:                    return (paramErr);
  488.         }
  489.         err = AECreateDesc(typeEnumeration, &anEnum, sizeof(anEnum), prefsDesc);
  490.         break;
  491.         
  492.     case prefsPR_FileName:
  493.         err = AECreateDesc(typeChar, prefsData.outfile+1, StrLength(prefsData.outfile), prefsDesc);
  494.         break;
  495. #endif
  496.     default:
  497.         err = errAECantHandleClass;
  498.         break;
  499.     }
  500.     
  501.     return (err);
  502. }
  503.  
  504. /*
  505.  *    SetPref        -    set a specified Preference setting from an AppleEvent request
  506.  *
  507.  */
  508.  
  509. static short SetPref(AEKeyword keyword, const AEDesc *prefsDesc, Handle settings)
  510. {
  511.     SetFilePref    prefsData    = ** (SetFilePrefHandle) settings;
  512.     AEDesc            toDesc    = { typeNull, NULL };
  513.     OSErr            err        = noErr;
  514.     Handle            dataHand;
  515.     Size            textLength;
  516.     DescType        anEnum;
  517. #pragma unused(prefsDesc,anEnum,textLength,dataHand)
  518.     switch (keyword)
  519.     {
  520. #if 0
  521.     case prefsLN_GenerateSymFile:
  522.         if (prefsDesc->descriptorType == typeBoolean)
  523.         {
  524.             dataHand = prefsDesc->dataHandle;
  525.         }
  526.         else
  527.         {
  528.             err = AECoerceDesc(prefsDesc, typeBoolean, &toDesc);
  529.             if (err == noErr)
  530.                 dataHand = toDesc.dataHandle;
  531.         }
  532.         if (err == noErr)
  533.         {
  534.             prefsData.linksym = ** (Boolean **) dataHand;
  535.         }
  536.         break;
  537.         
  538.     case prefsPR_ProjectType:
  539.         if (prefsDesc->descriptorType != typeEnumeration)
  540.         {
  541.             err = errAETypeError;
  542.             break;
  543.         }
  544.  
  545.         anEnum = ** (DescType **) prefsDesc->dataHandle;
  546.         
  547.         switch (anEnum)
  548.         {
  549.         case enum_Project_Application:        prefsData.projtype = kProjTypeApplication;    break;
  550.         case enum_Project_Library:            prefsData.projtype = kProjTypeLibrary;        break;
  551.         case enum_Project_SharedLibrary:    prefsData.projtype = kProjTypeSharedLib;    break;
  552.         case enum_Project_CodeResource:        prefsData.projtype = kProjTypeCodeResource;    break;
  553.         case enum_Project_MPWTool:            prefsData.projtype = kProjTypeMPWTool;        break;
  554.         default:                            return (errAECoercionFail);
  555.         }
  556.         break;
  557.         
  558.     case prefsPR_FileName:
  559.         if (prefsDesc->descriptorType == typeChar)
  560.         {
  561.             dataHand = prefsDesc->dataHandle;
  562.         }
  563.         else
  564.         {
  565.             err = AECoerceDesc(prefsDesc, typeChar, &toDesc);
  566.             if (err == noErr)
  567.                 dataHand = toDesc.dataHandle;
  568.         }
  569.         if (err == noErr)
  570.         {
  571.             textLength = GetHandleSize(dataHand);
  572.             if (textLength > sizeof(prefsData.outfile) - 1)
  573.                 textLength = sizeof(prefsData.outfile) - 1;
  574.             BlockMoveData(*dataHand, prefsData.outfile+1, textLength);
  575.             prefsData.outfile[0] = textLength;
  576.         }
  577.         break;
  578. #endif
  579.     default:
  580.         err = errAECantHandleClass;
  581.         break;
  582.     }
  583.     
  584.     if (err == noErr)
  585.     {
  586.         ** (SetFilePrefHandle) settings = prefsData;
  587.     }
  588.     
  589.     AEDisposeDesc(&toDesc);
  590.     
  591.     return (err);
  592. }
  593.  
  594. /*
  595.  *    GetFactory    -    retrieve factory settings
  596.  *
  597.  */
  598.  
  599. static short GetFactory(Handle settings)
  600. {
  601.     Handle    factory;
  602.     Size    size;
  603.     OSErr    err;
  604.     
  605.     factory = Get1Resource('pref', kFactoryPrefsID);
  606.     if (factory == NULL) {
  607.         err = ResError();
  608.         if (err == noErr)
  609.             err = resNotFound;
  610.         return (err);
  611.     }
  612.     
  613.     size = GetHandleSize(factory);
  614.     SetHandleSize(settings, size);
  615.     err = MemError();
  616.     
  617.     if (err == noErr) {
  618.         BlockMoveData(*factory, *settings, size);
  619.     }
  620.     
  621.     return (err);
  622. }
  623.  
  624. /*
  625.  *    UpdatePref    -    "upgrade" a pref to the current version
  626.  *
  627.  */
  628.  
  629. static short UpdatePref(Handle settings)
  630. {
  631. #if 0
  632.     typedef struct SetFilePref_V1 {
  633.         short    version;        // version # of pref information
  634.         short    projtype;        // project type
  635.         Str32    outfile;        // output file name
  636.     } SetFilePref_V1;
  637.     
  638.     typedef struct SetFilePref {
  639.         short    version;        // version # of pref information
  640.         short    projtype;        // project type
  641.         Str32    outfile;        // output file name
  642.         Boolean    linksym;        // generate SYM file
  643.     } SetFilePref_V2;
  644.     
  645.     SetFilePref_V1        v1;
  646.     SetFilePref_V2        v2;
  647. #endif
  648.     SetFilePrefHandle    prefsHand    = (SetFilePrefHandle) settings;
  649.     OSErr                err        = noErr;
  650.     
  651.     switch ((*prefsHand)->version)
  652.     {
  653. #if 0
  654.     case 1:
  655.         /* convert from version 1 to version 2 */
  656.         v1 = ** (SetFilePref_V1 **) prefsHand;
  657.         GetFactory(settings);
  658.         (*prefsHand)->projtype = v1.projtype;
  659.         BlockMoveData(v1.outfile, (*prefsHand)->outfile, sizeof(v1.outfile));
  660.         break;
  661.         
  662.     case 2:
  663.         /* convert from version 1 to version 2 */
  664.         v2 = ** (SetFilePref_V2 **) prefsHand;
  665.         GetFactory(settings);
  666.         (*prefsHand)->projtype = v2.projtype;
  667.         (*prefsHand)->linksym = v2.linksym;
  668.         BlockMoveData(v1.outfile, (*prefsHand)->outfile, sizeof(v1.outfile));
  669.         break;
  670.         
  671.     case PSAMPLEPANELVERSION:
  672.         break;
  673. #endif
  674.         
  675.     default:
  676.         err = kBadPrefVersion;
  677.         break;
  678.     }
  679.     
  680.     return (err);
  681. }
  682.  
  683. /*
  684.  *    ComparePrefs
  685.  *
  686.  */
  687. static Boolean    ComparePrefs(Handle prefsHand1, Handle prefsHand2)
  688. {
  689.     SetFilePrefHandle    prefs1    = (SetFilePrefHandle) prefsHand1;
  690.     SetFilePrefHandle    prefs2    = (SetFilePrefHandle) prefsHand2;
  691.     
  692.     return (
  693.         ((*prefs1)->version  == (*prefs2)->version) && 
  694.         ((*prefs1)->creator  == (*prefs2)->creator) && 
  695.         ((*prefs1)->type  == (*prefs2)->type) && 
  696.         ((*prefs1)->bits.alias  == (*prefs2)->bits.alias) && 
  697.         ((*prefs1)->bits.invisible  == (*prefs2)->bits.invisible) && 
  698.         ((*prefs1)->bits.bundle  == (*prefs2)->bits.bundle) && 
  699.         ((*prefs1)->bits.system  == (*prefs2)->bits.system) && 
  700.         ((*prefs1)->bits.stationary  == (*prefs2)->bits.stationary) && 
  701.         ((*prefs1)->bits.customIcon  == (*prefs2)->bits.customIcon) && 
  702.         ((*prefs1)->bits.inited  == (*prefs2)->bits.inited) && 
  703.         ((*prefs1)->bits.shared  == (*prefs2)->bits.shared) && 
  704.         ((*prefs1)->bits.onDesk  == (*prefs2)->bits.onDesk) && 
  705.         ((*prefs1)->xbits.routing  == (*prefs2)->xbits.routing) && 
  706.         ((*prefs1)->xbits.badge  == (*prefs2)->xbits.badge));
  707. }
  708.